<?php

/**
 * 新闻
 */

namespace app\api\controller\news;

use app\api\controller\Common;

class Article extends Common
{
    protected $data;
    public function initialize()
    {
        parent::initialize();
        $this->data = $this->request->except(['sign', 'accessKey', 'token']);
    }

    public function detail()
    {
        $id = input('id');
        $detail = db('article')->field('id,title,content,create_time')->where('id', $id)->find();
        if ($detail) {
            db('article')->where('id', $id)->setInc('hit'); // 浏览量+1
           
            $this->return = ['code' => 'SUCCESS', 'status' => 200, 'message' => '成功', 'data' => $detail];
        } else {
            $this->return = ['code' => 'GET_ERROR', 'status' => 200, 'message' => '无数据'];
        }
        return $this->show($this->return);
    }

   
}
